package com.doge.calcalbum.business.trash

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.doge.calcalbum.db.model.Entry

class TrashViewModel(
    private val repository: TrashRepository
) : ViewModel() {
    val entryList = repository.entryList
    fun recover(entries: List<Entry>) = repository.recover(entries)
    fun delete(entries: List<Entry>) = repository.delete(entries)
}

class TrashViewModelFactory : ViewModelProvider.Factory {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        val repository = TrashRepository()
        if (modelClass.isAssignableFrom(TrashViewModel::class.java)) {
            return TrashViewModel(repository) as T
        }
        //noinspection unchecked
        throw IllegalArgumentException("Unknown ViewModel class")
    }
}
